﻿using System;
using System.Collections.Generic;
using BlockLogic.Impl.Controller;
using BlockLogic.Interface.Blocks;
using BlockLogic.Interface.Blocks.Checker;
using CommandLogic.Interface;

namespace CommandLogic.Impl
{
    public class ConnectBlocksCommand : ICommandLogic
    {
        private static ConnectBlocksCommand instance = new ConnectBlocksCommand();

        private ConnectBlocksCommand(){}

        public static ConnectBlocksCommand getInstance()
        {
            return instance;
        }

        public Dictionary<string, object> execute(Dictionary<string, object> param)
        {
            var idSink = (Guid)param["idSink"];
            var idSource = (Guid)param["idSource"];

            var blockController = BlockController.GetInstance();

            var sourceBlock = (IOutputBlock)blockController[idSource];
            var sinkBlock = (IInputBlock)blockController[idSink];

            blockController.Connect(sinkBlock,sourceBlock);

            return null;
        }
    }
}
